<include file='Admin/Tpl/Public/nav.html' />
<div class="page-content">
    <div class="container-fluid">
    	<br/>
        <ol class="breadcrumb default square rsaquo sm">
            <li><a href="index.html"><i class="fa fa-home"></i></a></li>
            <li><a href="#fakelink">Teamin</a></li>
            <li class="active">新闻管理</li>
        </ol>

        <div class="the-box no-border">
        
            <div class="table-responsive div1 div_search">
                <table class="table table-th-block table-hover">
                    <thead>
                    <tr style="text-align:center">
                        <td style="width:3%"><input type="checkbox" disabled /></td>
                        <td style="text-align:center;width:60px">编号</td>
                        <td style="text-align:center;width:80px">缩略图</td>
                        <td style="text-align:center">标题</td>
                        <td style="text-align:center;width:180px">添加时间</td>
                        <td style="text-align:center;width:100px">查看评论</td>
                        <td style="text-align:center;width:80px">显示状态</td>
                        <td style="text-align:center;width:180px">操作</td>
                      </tr>
                    </thead>
                    <form action="__URL__/deleteall" method="post">
                        <tbody>
                            <volist name="rs.data" id="val"> 
                              <tr>
                                <td style="width:3%">                                           
                                    <input type="checkbox" class="checkboxes" value="{$val.news_id}" name="id[]"/>
                                </td>                    
                                <td style='text-align:center;vertical-align:middle'>{$val.news_id}</td>
                                <td style='text-align:center;vertical-align:middle'>
                                    <img src="__ROOT__/{$val.news_image_s}" height="25" />
                                </td>
                                <td style='text-align:center;vertical-align:middle'>
                                    <a href="__ROOT__/{$val.news_url}" target="_blank">{$val.news_title}</a>
                                </td>
                                <td style='text-align:center;vertical-align:middle'>{$val.news_time}</td>
                                <th style="text-align:center" style="width:120px"><a href="javascript:void(0)" onclick="open_suggest({$val.news_id})">查看评论({$val.news_comment_count})</a></th>
                                <td style='text-align:center;vertical-align:middle'>
                                    <if condition="$val.news_display eq 1">显示
                                    <else /> 隐藏
                                    </if>
                                </td>
                                <td style='text-align:center;vertical-align:middle'>
                                    <if condition="$val.news_display eq 1">
                                    <a href="javascript:void(0)" onclick="for_display({$val.news_id},0)">隐藏</a>&nbsp;|&nbsp;
                                    <else />
                                    <a href="javascript:void(0)" onclick="for_display({$val.news_id},1)">显示</a>&nbsp;|&nbsp;
                                    </if>
                                    <if condition="$_GET['category'] == 1"><a href='javascript:void(0)' onclick="push_this_news({$val.news_id})" title='Edit'>推送</a>&nbsp;|&nbsp;</if>
                                    
                                    <a href='javascript:void(0)' onclick="to_upt({$val.news_id})" title='Edit'>修改</a>&nbsp;|&nbsp;
                                    <a href='javascript:void(0)' onclick='del_news({$val.news_id})' title='Delete'>删除</a>
                                </td>
                              </tr>
                            </volist>
                            <tr>
                                <td style="text-align:center；border-right:0px;" colspan="3">
                                    <button type="button" class="button">全选</button>
                                    <button type="button" class="button">反选</button>
                                    <input type="submit" class="button" value="删除" onclick="return confirm(' 你确定要删除吗？')">
                                </td>
                            </tr>
                        </tbody>
                    </form>
                </table>
                <ul class="pagination success">{$rs.show}</ul>
            </div>

            <div class="table-responsive" id="hl"></div>

        </div>
    </div>
</div>
</div>


</body>
</html>
<script src="__PUBLIC__/assets/js/jquery.min.js"></script>
<script type="text/javascript">
function del_news(a){
	if(confirm("确认删除?")){
		$.get('__URL__/del_news?news_id='+a,'',function(){window.location='__SELF__';},'json');	
	}
}
function to_upt(a){
	window.location='__URL__/to_update?news_id='+a;
	//$.jBox.open("iframe:__URL__/to_update?news_id="+a, "修改", 900, 500, { buttons: { '关闭': true},closed: function () { window.location='__SELF__' }});
}
function for_display(news_id,news_dispaly){
	$.get('__URL__/news_display?news_display='+news_dispaly+'&news_id='+news_id,'',function(){window.location='__SELF__'});	
}
function open_suggest(a){
	$.jBox.open("iframe:__URL__/check_suggest?news_id="+a, "查看建议", 900, 500, { buttons: { '关闭': true},closed: function () { window.location='__SELF__' }});
}
function push_this_news(a){
	if(confirm('推送过程请在页面提示推送成功再进行后续操作')){
		$.ajax({
			type:"post",
			url:"__APP__/Base/Noti/push_news",
			data: "news_id="+a,
			dataType:"json",
			beforeSend: function(){
					$("#dig").show();
				},
			success:function(data){
				if(data.state==1){
					$("#dig").hide();
					alert('推送成功');	
				}else{
					alert('推送失败');	
				}
			}
		});
	}
}

$(function () {         
    var bool = true;
    $(':button:contains(全选)').bind('click',function(){
        // 全选一定有标示状态
        $(':checkbox[name="id[]"]').each(function(){
            $(this).prop('checked',bool);
        });
        bool=!bool;
    });

     $(':button:contains(反选)').bind('click',function(){     
        $(':checkbox[name="id[]"]').each(function(){
            $(this).prop('checked',!this.checked);
        });
     });
 })
</script>
